#!/usr/bin/python

import os, sys, numpy

Tc = 2.269
checkerboard_method = 0
random_method = 1
checkerboard_random_method = 2

program = './2d'
hs = list(numpy.arange (0.37, 0.51, 0.02))
taus = [4*Tc/9]
ms = [random_method, checkerboard_method]
av = 50

output = 'trial'

def append_extension (output, m):
	if m == checkerboard_method:
		output += '.chk'
	elif m == random_method:
		output += '.ran'
	elif m == checkerboard_random_method:
		output += '.chr'
	else:
		print 'Invalid method, can not assign output name accordingly.'
	return output

iteration = 0
tot_iteration = len(hs)*len(taus)*len(ms)*av

print 'Programs dispatched...'

for m in ms:
	for h in hs:
		# Taus tend to be constant
		for tau in taus:
			for a in xrange (0, av):
				#output = "trial_"+"_"+str(h)+"_"+str(tau)+"_"+str(a)
				output = "trial"+"_"+str(h)+"_"+str(a)
				output = append_extension (output, m)
				sys.stdout.write('\r'+str(iteration)+'/'+str(tot_iteration)+' iterations completed.')
				sys.stdout.flush ()
				# Execute the program
				os.system (str(program)+' '+str(output)+' '+str(h)+' '+str(tau)+' '+str(m))
				iteration += 1

print '\nPrograms completed.'
